package com.jishucai;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author admin
 */
public class SomeChanelInitializer extends ChannelInitializer<SocketChannel> {

    // channel创建完成后就会触发该方法的执行，用于初始化channel
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline channelPipeline = socketChannel.pipeline();

        //HttpServerCodec 放入到 pipeline
        channelPipeline.addLast(new HttpServerCodec());
        // 将自定义的处理器放到最后面
        channelPipeline.addLast(new SomeServerHandler());
    }
}
